package com.dongbo.recorder.screenrecord.adapter;

import android.graphics.Paint;
import android.text.TextUtils;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.dongbo.recorder.screenrecord.bean.VipInfo;
import com.dongbo.recorder.screenrecord.R;

/**
 * @author GuoZi
 * @date :2020/5/4 14:43
 * @description:
 */
public class VipAdapter extends BaseQuickAdapter<VipInfo, BaseViewHolder> {
    //选中
    private int choose = 0;

    public VipAdapter() {
        super(R.layout.adapter_vip);
    }

    @Override
    protected void convert(BaseViewHolder baseViewHolder, VipInfo data) {
        baseViewHolder.setText(R.id.adapter_vip_name, data.getName());
        if (choose == baseViewHolder.getLayoutPosition()) {
            baseViewHolder.setBackgroundResource(R.id.adapter_vip_item, R.drawable.bg_vip_choose)
                    .setGone(R.id.adapter_vip_choose, false);
        } else {
            baseViewHolder.setBackgroundResource(R.id.adapter_vip_item, R.drawable.bg_vip_unchoose)
                    .setGone(R.id.adapter_vip_choose, true);
        }
        baseViewHolder.setText(R.id.adapter_vip_name, data.getName());
        baseViewHolder.setText(R.id.adapter_vip_price, TextUtils.isEmpty(data.getPrice()) ? "" : data.getPrice());
        baseViewHolder.setText(R.id.adapter_vip_oldprice, TextUtils.isEmpty(data.getPrice()) ? "" : "￥" + data.getOldPrice());
        //中划线
        TextView adapter_vip_oldprice = baseViewHolder.getView(R.id.adapter_vip_oldprice);
        adapter_vip_oldprice.getPaint().setFlags(Paint.STRIKE_THRU_TEXT_FLAG);
    }

    public int getChoose() {
        return choose;
    }

    public void setChoose(int choose) {
        this.choose = choose;
        notifyDataSetChanged();
    }
}
